/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package kn.cstf2.users.Shared;

import java.util.ArrayList;
import kn.cstf2.global.Utils.CstF2Exception;
import kn.cstf2.users.Bean.UsersBean;
import kn.cstf2.users.Server.UsersServer;

/**
 *
 * @author user1
 */
public class UsersShared {

    UsersServer usersServer = new UsersServer();

    public ArrayList<String> GetUsersWithSameNameAndEmail(String name, String email) {
        ArrayList<String> users = new ArrayList<String>();
        users = usersServer.ObternerUsersWithSameNameAndEmail(name, email);
        return users;
    }

    public ArrayList<UsersBean> GetUsersByName(String name) {
        ArrayList<UsersBean> users = new ArrayList<UsersBean>();
        users = usersServer.ObternerUsersByName(name);
        return users;
    }

    public ArrayList<StringBuilder> GetModificarUsersByName(String name) {
        ArrayList<StringBuilder> users = new ArrayList<StringBuilder>();
        users = usersServer.ObternerModificarUsersByName(name);
        return users;
    }

    public UsersBean GetUserInfo(Integer idUser) {
        UsersBean userBean = new UsersBean();
        if (idUser != null) {
            userBean = usersServer.ObternerUsersInfo(idUser);
        } else {
            throw new CstF2Exception("El Usuario es null");
        }
        return userBean;
    }

    public void UpdateUserDataByBean(UsersBean usersBean) {
        if (usersBean != null) {
            usersServer.ActualizarUserDataByBean(usersBean);
        } else {
            throw new CstF2Exception("El Usuario es null");
        }
    }

    public void DeleteUserClientDependences(Integer idUserSelected) {
        int s;
        s = idUserSelected;
        if (idUserSelected != null) {
            usersServer.BorrarUserClientDependences(idUserSelected);
        } else {
            throw new CstF2Exception("El Usuario es null");
        }
    }

    public void DeleteUserClient(Integer idUserSelected) {
        int s;
        s = idUserSelected;

        if (idUserSelected != null) {
            usersServer.BorrarUserClient(idUserSelected);
        } else {
            throw new CstF2Exception("El Usuario es null");
        }
    }

    public void SaveNewUser(UsersBean userBean) {
        usersServer.GuardaNewUser(userBean);
    }
}
